<?php
include_once($_SERVER['DOCUMENT_ROOT']."/RecJP/inc/session_start.php");
header("content-type:application/json; charset=utf-8");
include_once($_SERVER['DOCUMENT_ROOT'] . "/RecJP/class/DAL/DAL.userMemory.php");
//include_once($_SERVER['DOCUMENT_ROOT']."/RecJP/class/Model/Model.userMemory.php");
$data = null;
if (isset($_POST['data'])) {
    $data = $_POST['data'];
}
$s = "";
try {
    foreach ($data as $value) {
        $userMemory = new Model_userMemory();
        $userMemory->userid = $_SESSION['userid'];
        $userMemory->username = $_SESSION['username'];
        $userMemory->wordid = $value["id"];
        $userMemory->memory = $value["score"];
        //$userMemory->testCount=$value["score"];
        //$userMemory->testerrorCount=$value["score"];
        DAL_userMemory::insertOrUpdate($userMemory);
    }
} catch (Exception $e) {
    $s = "0";
    die("Error!: " . $e->getMessage() . "<br/>");
}
$s = "1";
$arr = array();
$arr["returnval"] = $s;
echo json_encode($arr); //���json��� 
//echo "{\"returnval\":\"1\"}"; //���json��� 


